package pwd.allen;

public class SpeedUtil {

    public static final Integer refeshMills = 25;

    private Runnable runnable;

    private Integer interval;

    private Long lastRunMills;

    public SpeedUtil(Runnable runnable, int interval) {
        this.runnable = runnable;
        this.interval = interval;
    }
    public void run() {
        if (lastRunMills == null || System.currentTimeMillis() - lastRunMills > interval) {
            if (runnable != null) {
                runnable.run();
            }
            lastRunMills = System.currentTimeMillis();
        }
    }
}
